package cn.wolfcode.web.controller;

import cn.wolfcode.qo.JsonResult;
import cn.wolfcode.service.IEmployeeService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * ClassName LoginController
 * Create by Mike
 * Date 2021/8/12 21:37
 */
@Controller
public class LoginController {

    @Autowired
    private IEmployeeService employeeService;

    @RequestMapping("/login")
    @ResponseBody
    public JsonResult login(String username, String password){

        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken token = new UsernamePasswordToken(username, password);
        subject.login(token);
        return new JsonResult(true,"登录成功");

      /*  Employee employee = employeeService.login(username,password);
        if (employee == null){
            return new JsonResult(false,"登陆失败");
        }
        //登录成功
        UserContext.setEmployee(employee);
        return new JsonResult(true,"登录成功");*/
    }


}
